{% extends "main/base.html" %}
{% load i18n static main_tag %}
{% block title %}{% trans '服务记录' %}{% endblock %}
{% block this_css %}
<link rel="stylesheet" type="text/css" href="{% static 'flatlab/css/bootstrap-select.min.css' %}">
{% endblock %}
{% block content %}
<section class="panel">
    <div class="panel-body">
        <div class="col-md-9">
            <form class="form-inline" role="form" method="get">
                <div class="form-group">
                    <select name="c" class="selectpicker show-tick form-control" data-live-search="true">
                        <option value="">{% trans '所有状态' %}</option>
                        {% for ss in service_states %}
                            {% if ss.pk|floatformat:'0' == request.GET.c|floatformat:'0' %}
                            <option value="{{ ss.pk }}" selected>{{ ss }}</option>
                            {% else %}
                            <option value="{{ ss.pk }}" >{{ ss }}</option>
                            {% endif %}
                        {% endfor %}
                    </select>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon">{% trans '起始' %}:</span>
                        <input type="date" name="s" class="form-control" value="{% if request.GET.s %}{{ request.GET.s }}{% endif %}">
                    </div>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <span class="input-group-addon">{% trans '截止' %}:</span>
                        <input type="date" name="e" class="form-control" value="{% if request.GET.e %}{{ request.GET.e }}{% endif %}">
                    </div>
                </div>
                <div class="form-group">
                    <div class="input-group">
                        <input class="form-control" type="text" name="q" placeholder="" value="{% if request.GET.q %}{{ request.GET.q }}{% endif %}">
                        <span class="input-group-btn"><button class="btn btn-primary" type="submit">搜索</button></span>
                    </div>
                </div>
            </form>
        </div>
        <div class="col-md-3" align="right">{% if perms.main.add_servicerecord %}
            <a href="{% url 'main:service_record_create' %}?next={{ request.path }}"><button type="button" class="btn btn-success">{% trans "添加服务记录" %}</button></a>{% endif %}
        </div>
    </div>
</section>
<section class="panel">
    {% get_current_language as LANGUAGE_CODE %}
    <div class="table-responsive panel-body">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>{% trans 'No.' %}</th>
                    <th>{% trans '关联订单' %}</th>
                    <th>{% trans '客户名字' %}</th>
                    <th>{% trans '联系方式' %}</th>
                    <th>{% trans '概述' %}</th>
                    <th>{% trans '销售' %}</th>
                    <th>{% trans '详情' %}</th>
                    <th>{% trans '状态' %}</th>
                    <th>{% trans '最后更新' %}</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>{% for d in page_obj %}
                <tr>
                    <td>{{ d.pk }}</td>
                    <td>{{ d.related_order.order_code }}</td>
                    <td>{{ d.related_order.client.name }}</td>
                    <td>{{ d.related_order.client.mobile|mobile }}</td>
                    <td>{{ d.title }}</td>
                    <td>{{ d.salesman.name }}</td>
                    <td>{{ d.remarks|linebreaks }}</td>
                    <td>{{ d.service_state.service_state_cn }}</td>
                    <td>{{ d.datetime_updated }}</td>{% if perms.main.change_servicerecord %}
                    <td align="right"><a href="{% url 'main:service_record_update' d.pk %}"><button class="btn btn-success btn-xs"><i class="fa fa-pencil"></i></button></a></td>{% endif %}
                </tr>{% endfor %}
            </tbody>
        </table>
        <div align="right">
            {% include 'main/tablenav.html' %}
        </div>
    </div>
</section>
{% endblock %}
{% block this_js %}
<script type="text/javascript" src="{% static 'flatlab/js/bootstrap-select.min.js' %}"></script>
{% endblock %}